const common = {
	props:{
		index:{ //
			type: Number,
			default: 0
		},
		showChecked: { //显示选择框
			type: Boolean,
			default: false
		},
		showRightAnswer: { //显示正确答案
			type: Boolean,
			default: true
		},
		showExplanation: { //显示解析
			type: Boolean,
			default: true
		},
		showAnswerResult: { //显示答题结果：正确/错误
			type: Boolean,
			default: false
		},
		showUserAnswer:{ //显示用户回答
			type: Boolean,
			default: false
		},
		showScore: { //显示分数
			type: Boolean,
			default: true
		},
		pattern:{ //模式 ：答题/显示
			type: String,
			default: 'show',
			validator(value) {
				return ['show','answer'].includes(value)
			},
		},
		disabledAnswer:{
			type: Boolean,
			default: true
		}
	},
	data(){
		return {
			errorImg: require('../images/error.png'),
			correctImg: require('../images/correct.png')
		}
	},
	filters: {
		difficultyFilter: (val) => {
			let difficultyStr = '';
			if(val) {
				val = val.toLowerCase();
			}
			switch(val) {
				case 'simple':
					difficultyStr = '简单';
					break;
				case 'commonly':
					difficultyStr = '一般';
					break;
				case 'medium':
					difficultyStr = '中等';
					break;
				case 'hard':
					difficultyStr = '较难';
					break;
			}
			return difficultyStr;
		},
		modeFilter: (val) => {
			let str = '';
			if(val) {
				val = parseInt(val);
			}
			switch(val) {
				case 1:
					str = '单选';
					break;
				case 2:
					str = '多选';
					break;
				case 3:
					str = '判断';
					break;
				case 4:
					str = '填空';
					break;
				case 5:
					str = '简答';
					break;
			}
			return str;
		},
		filterIsPublic(type) {
			//1--单位  2--未单位
			let status = '';
			if(type === 'share') {
				status = '单位'
			} else if(type === 'private') {
				status = '个人'
			}else if(type === 'public'){
				status = '系统'
			}
			return status;
		}
	},
	created(){
		
	},
	methods:{
		answerRight(){
			return this.question.answerResult === 1 
			|| this.question.answerResult === '1' 
			|| this.question.answerResult === true
			|| this.question.answerResult === 'right'
			|| this.question.answerResult === 'correct'
		},
		handleSelect($event,question){
			this.$emit('handleSelect',$event,question);
		},
	}
}
export default common